<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>剖析Document对象</title>
    <style type="text/css">
        .container {
            border: 1px solid blue;
            margin: 15px;
        }
        
        .container div {
            line-height: 36px;
            border-bottom: 1px solid #dedede;
        }
    </style>
</head>

<body>
    <div class="container first">
        <h3>Document</h3>
    </div>
    <div class="container second">
        <h3>Document.prototype</h3>
    </div>
    <script type="text/javascript">
        // 选择页面上 class 属性取值中 包含 first 的第一个元素
        let firstContainer = document.querySelector('.first');
        let names = Object.getOwnPropertyNames(Document);
        names.forEach(e => {
            let d = document.createElement('div');
            d.innerText = 'Document.' + e;
            firstContainer.appendChild(d);
        });
        // 选择页面上 匹配于 .second 选择器 的第一个元素
        let secondContainer = document.querySelector('.second');
        names = Object.getOwnPropertyNames(Document.prototype);
        names.forEach(e => {
            let d = document.createElement('div');
            d.innerText = 'Document.prototype.' + e;
            secondContainer.appendChild(d);
        });
    </script>
</body>

</html>